import request from "@/utils/request";
//上传图片
export function uploadPictures(data) {
  return request({
    url: "/upload",
    method: "post",
    data,
  });
}

//注册
export function register(data) {
  return request({
    url: "/regUser",
    method: "post",
    data,
  });
}
//用户信息录入 ?
export function addUserInfo(data) {
  return request({
    url: "/addUserInfo",
    method: "post",
    data,
  });
}
//登录
export function login(data) {
  return request({
    url: "/login",
    method: "post",
    data,
  });
}
//获取用户信息
export function getInfo(user_id) {
  return request({
    url: "/userInfo",
    method: "get",
    params: { user_id },
  });
}
//更新用户信息
export function updateInfo(data) {
  return request({
    url: "/updateUserInfo",
    method: "post",
    data,
  });
}
//更新用户密码
export function updatePwd(data) {
  return request({
    url: "/updatePwd",
    method: "post",
    data,
  });
}

//管理员获取所有用户信息
export function getAllUserInfo() {
  return request({
    url: "/getAllUserInfo",
    method: "get",
  });
}

//--------------------商品管理-----------------------------------------
//根据用户id收藏获取推荐商品信息
export function getRecommendProductsByUserId(user_id) {
  return request({
    url: "/getRecommendProductsByUserId",
    method: "get",
    params: { user_id },
  });
}

//条件获取商品信息 category_id：分类搜索 product_name：模糊搜索 status:0/1上下架
export function getAllProducts(params) {
  return request({
    url: "/getAllProducts",
    method: "get",
    params,
  });
}
//新增商品信息
export function addProducts(data) {
  return request({
    url: "/addProducts",
    method: "post",
    data,
  });
}

//删除商品信息
export function deleteProducts(product_id) {
  return request({
    url: "/deleteProducts",
    method: "get",
    params: { product_id },
  });
}

//修改商品信息
export function updateProducts(data) {
  return request({
    url: "/updateProducts",
    method: "post",
    data,
  });
}
//--------------------订单管理-----------------------------------------
//获取所有订单
export function getAllOrders() {
  return request({
    url: "/getAllOrders",
    method: "get",
  });
}
//根据用户id获取所有订单信息或者根据订单状态获取 user_id status
export function getAllOrdersByUserId(params) {
  return request({
    url: "/getAllOrdersByUserId",
    method: "get",
    params,
  });
}
//管理员根据status获取列表
export function getAllOrdersByStatus(status) {
  return request({
    url: "/getAllOrdersByStatus",
    method: "get",
    params: { status },
  });
}
//新增订单信息
export function addOrders(data) {
  return request({
    url: "/addOrders",
    method: "post",
    data,
  });
}
//删除订单信息
export function deleteOrders(order_id) {
  return request({
    url: "/deleteOrders",
    method: "get",
    params: { order_id },
  });
}
//修改订单信息
export function updateOrders(data) {
  return request({
    url: "/updateOrders",
    method: "post",
    data,
  });
}
//--------------------订单详情管理-----------------------------------------
//批量新增订单详情信息
export function addOrderdetailsByList(data) {
  return request({
    url: "/addOrderdetailsByList",
    method: "post",
    data,
  });
}
//根据订单id获取所有订单详情信息
export function getAllOrderdetailsByOrderId(order_id) {
  return request({
    url: "/getAllOrderdetailsByOrderId",
    method: "get",
    params: { order_id },
  });
}
//新增订单详情信息
export function addOrderdetails(data) {
  return request({
    url: "/addOrderdetails",
    method: "post",
    data,
  });
}

//删除订单详情信息
export function deleteOrderdetails(order_detail_id) {
  return request({
    url: "/deleteOrderdetails",
    method: "get",
    data: { order_detail_id },
  });
}
//修改订单详情信息
export function updateOrderdetails(data) {
  return request({
    url: "/updateOrderdetails",
    method: "post",
    data,
  });
}
//批量删除订单详情信息 order_detail_ids
export function deleteBatchOrderdetails(data) {
  return request({
    url: "/deleteBatchOrderdetails",
    method: "post",
    data,
  });
}
//根据order_id批量删除订单详情信息
export function deleteBatchOrderdetailsByOrderId(order_id) {
  return request({
    url: "/deleteBatchOrderdetailsByOrderId",
    method: "get",
    params: { order_id },
  });
}
//根据订单详情统计商品分类下的销售总额可以根据时间段来筛选 start_time end_time

export function getTotalCategoryMoney(params) {
  return request({
    url: "/getTotalCategoryMoney",
    method: "get",
    params,
  });
}
//根据订单日期当日销售总额统计总金额 可以根据时间段来筛选 start_time end_time
export function getTotalMoneyByOrderDate(params) {
  return request({
    url: "/getTotalMoneyByOrderDate",
    method: "get",
    params,
  });
}
//------------------收藏管理------------------------------------
//根据用户id和商品id判断是否收藏该商品 user_id product_id
export function isFavorite(params) {
  return request({
    url: "/isFavorite",
    method: "get",
    params,
  });
}
//根据用户id获取所有收藏信息

export function getAllFavoritesByUserId(user_id) {
  return request({
    url: "/getAllFavoritesByUserId",
    method: "get",
    params: { user_id },
  });
}
//新增收藏信息
export function addFavorites(data) {
  return request({
    url: "/addFavorites",
    method: "post",
    data,
  });
}
//取消/删除收藏信息
export function deleteFavorites(data) {
  return request({
    url: "/deleteFavorites",
    method: "post",
    data,
  });
}
//取消/删除收藏信息 byid
export function deleteFavoritesById(favorite_id) {
  return request({
    url: "/deleteFavoritesById",
    method: "get",
    params: { favorite_id },
  });
}
//----------------评论管理--------------------
//根据商品id获取商品所有评论信息
export function getAllCommentsByProductId(product_id) {
  return request({
    url: "/getAllCommentsByProductId",
    method: "get",
    params: { product_id },
  });
}
//新增评论信息
export function addComments(data) {
  return request({
    url: "/addComments",
    method: "post",
    data,
  });
}
//删除评论信息
export function deleteComments(comment_id) {
  return request({
    url: "/deleteComments",
    method: "get",
    params: { comment_id },
  });
}
//修改评论信息
export function updateComments(data) {
  return request({
    url: "/updateComments",
    method: "post",
    data,
  });
}
//-------------分类管理---------------------------
//获取所有分类信息
export function getAllCategories() {
  return request({
    url: "/getAllCategories",
    method: "get",
  });
}
//新增分类信息
export function addCategories(data) {
  return request({
    url: "/addCategories",
    method: "post",
    data,
  });
}
//删除分类信息
export function deleteCategories(category_id) {
  return request({
    url: "/deleteCategories",
    method: "get",
    params: { category_id },
  });
}
//修改分类信息
export function updateCategories(data) {
  return request({
    url: "/updateCategories",
    method: "post",
    data,
  });
}
//---------------购物车管理--------------------------
//根据用户id获取所有购物车信息
export function getAllCartsByUserId(user_id) {
  return request({
    url: "/getAllCartsByUserId",
    method: "get",
    params: { user_id },
  });
}
//添加购物车
export function addCart(data) {
  return request({
    url: "/addCart",
    method: "post",
    data,
  });
}
//删除购物车
export function deleteCart(cart_id) {
  return request({
    url: "/deleteCart",
    method: "get",
    params: { cart_id },
  });
}
//修改购物车
export function updateCart(data) {
  return request({
    url: "/updateCart",
    method: "post",
    data,
  });
}
//----------------------------地址管理--------------------------
//根据用户id获取所有地址信息
export function getAllAddressByUserId(user_id) {
  return request({
    url: "/getAllAddressByUserId",
    method: "get",
    params: { user_id },
  });
}
//新增地址信息
export function addAddress(data) {
  return request({
    url: "/addAddress",
    method: "post",
    data,
  });
}
//删除地址信息
export function deleteAddress(address_id) {
  return request({
    url: "/deleteAddress",
    method: "get",
    params: { address_id },
  });
}
//修改地址信息
export function updateAddress(data) {
  return request({
    url: "/updateAddress",
    method: "post",
    data,
  });
}
